<template>
     <!-- <router-link to="/home"></router-link> -->
     <router-view />
     <van-tabbar route v-if="footTabBarShow">
          <van-tabbar-item replace to="/home" icon="home-o">首页</van-tabbar-item>
          <van-tabbar-item replace to="/register" icon="search">挂号</van-tabbar-item>
          <van-tabbar-item replace to="/user" icon="friends-o" @click="toCenter">个人中心</van-tabbar-item>
     </van-tabbar>
</template>

<script setup lang="ts">

import { Toast } from 'vant';
import { onMounted } from 'vue';
import router from './router';
import { ref } from "vue";
import $bus from "./config/eventBus";


//判断是否登录前往个人中心界面
const toCenter = () => {
     console.log(localStorage.getItem("loginStatus"));
     if (localStorage.getItem("loginStatus") === 'true') {
          router.push('/user')
     } else {
          router.push('/login')
          Toast.fail('请先登录，谢谢！')
     }
}


// 用于隐藏底部导航
let footTabBarShow = ref<boolean>(true)

// 接受参数实现动态隐藏底部导航
$bus.on("tabBarHide", status => {
     footTabBarShow.value = status as boolean;
})

</script>

<style lang="scss">

</style>
